<template>
  <div class="rights">
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">活动管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>活动列表</el-breadcrumb-item>
      <el-breadcrumb-item>活动详情</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card class="box-card">
      <el-table :data="rights" border strripe style="width: 100%">
        <el-table-column type="index" lebel="#"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="商品类型"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level === '0'">等级1</el-tag>
            <el-tag v-else-if="scope.row.level === '1'">等级2</el-tag>
            <el-tag v-else type="warning">等级3</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      rights: []
    }
  },

  created () {
    this.getRightsList()
  },

  methods: {
    async getRightsList () {
      const { data: res } = await this.$axios.get('rights/list')
      // console.log(res)
      // 判断请求成功或失败
      if (res.meta.status !== 200) return this.$message.error('获取权限列表失败')
      this.rights = res.data
      console.log(res)
    }
  }
}
</script>

<style scoped lang='less'>

</style>
